package org.fisco.bcos.sdk.demo.contract;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.codec.abi.FunctionEncoder;
import org.fisco.bcos.sdk.v3.codec.datatypes.Function;
import org.fisco.bcos.sdk.v3.codec.datatypes.Type;
import org.fisco.bcos.sdk.v3.codec.datatypes.TypeReference;
import org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.tuples.generated.Tuple10;
import org.fisco.bcos.sdk.v3.codec.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.v3.contract.Contract;
import org.fisco.bcos.sdk.v3.crypto.CryptoSuite;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.model.CryptoType;
import org.fisco.bcos.sdk.v3.model.TransactionReceipt;
import org.fisco.bcos.sdk.v3.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.v3.transaction.manager.transactionv1.ProxySignTransactionManager;
import org.fisco.bcos.sdk.v3.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class MultiTableTest extends Contract {
    public static final String[] BINARY_ARRAY = {"60c060405260066080819052651d17dd195cdd60d21b60a090815262000029916001919062000465565b503480156200003757600080fd5b50604051620011e2380380620011e28339810160408190526200005a9162000554565b60408051600a8082526101608201909252600091816020015b60608152602001906001900390816200007357905050905060405180604001604052806002815260200161076360f41b81525081600081518110620000bc57620000bc6200060c565b602002602001018190525060405180604001604052806002815260200161763160f01b81525081600181518110620000f857620000f86200060c565b6020026020010181905250604051806040016040528060028152602001613b1960f11b815250816002815181106200013457620001346200060c565b602002602001018190525060405180604001604052806002815260200161763360f01b815250816003815181106200017057620001706200060c565b6020026020010181905250604051806040016040528060028152602001611d8d60f21b81525081600481518110620001ac57620001ac6200060c565b602002602001018190525060405180604001604052806002815260200161763560f01b81525081600581518110620001e857620001e86200060c565b6020026020010181905250604051806040016040528060028152602001613b1b60f11b815250816006815181106200022457620002246200060c565b602002602001018190525060405180604001604052806002815260200161763760f01b815250816007815181106200026057620002606200060c565b6020026020010181905250604051806040016040528060028152602001610ec760f31b815250816008815181106200029c576200029c6200060c565b602002602001018190525060405180604001604052806002815260200161763960f01b81525081600981518110620002d857620002d86200060c565b602090810291909101810191909152604080516080810182526003918101918252626b657960e81b606082015290815280820183905283519091620003239160019186019062000465565b506040516318d2d28f60e11b8152611002906331a5a51e906200034e90600190859060040162000735565b6020604051808303816000875af11580156200036e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003949190620007d2565b5060405163f23f63c960e01b81526000906110029063f23f63c990620003c090600190600401620007fe565b602060405180830381865afa158015620003de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000404919062000813565b90506001600160a01b0381166200043b5760405162461bcd60e51b8152602060048201526000602482015260440160405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055506200083e915050565b828054620004739062000622565b90600052602060002090601f016020900481019282620004975760008555620004e2565b82601f10620004b257805160ff1916838001178555620004e2565b82800160010185558215620004e2579182015b82811115620004e2578251825591602001919060010190620004c5565b50620004f0929150620004f4565b5090565b5b80821115620004f05760008155600101620004f5565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200053e57818101518382015260200162000524565b838111156200054e576000848401525b50505050565b6000602082840312156200056757600080fd5b81516001600160401b03808211156200057f57600080fd5b818401915084601f8301126200059457600080fd5b815181811115620005a957620005a96200050b565b604051601f8201601f19908116603f01168101908382118183101715620005d457620005d46200050b565b81604052828152876020848701011115620005ee57600080fd5b6200060183602083016020880162000521565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806200063757607f821691505b602082108114156200065957634e487b7160e01b600052602260045260246000fd5b50919050565b8054600090600181811c90808316806200067a57607f831692505b60208084108214156200069d57634e487b7160e01b600052602260045260246000fd5b83885260208801828015620006bb5760018114620006cd57620006fa565b60ff19871682528282019750620006fa565b60008981526020902060005b87811015620006f457815484820152908601908401620006d9565b83019850505b5050505050505092915050565b600081518084526200072181602086016020860162000521565b601f01601f19169290920160200192915050565b6040815260006200074a60408301856200065f565b60208382038185015284516040835262000768604084018262000707565b9050818601518382038385015281935080518083528383019450838160051b840101848301925060005b82811015620007c457601f19858303018752620007b182855162000707565b9686019693860193915060010162000792565b509998505050505050505050565b600060208284031215620007e557600080fd5b81518060030b8114620007f757600080fd5b9392505050565b602081526000620007f760208301846200065f565b6000602082840312156200082657600080fd5b81516001600160a01b0381168114620007f757600080fd5b610994806200084e6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063693ec85e1461003b578063e942b5161461006d575b600080fd5b61004e610049366004610555565b610082565b6040516100649a999897969594939291906105ee565b60405180910390f35b61008061007b3660046106c9565b610272565b005b60608060608060608060608060608060008060009054906101000a90046001600160a01b03166001600160a01b031663fcd7e3c18d6040518263ffffffff1660e01b81526004016100d3919061072d565b600060405180830381865afa1580156100f0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610118919081019061078c565b90508060200151600081518110610131576101316108a2565b60200260200101518160200151600181518110610150576101506108a2565b6020026020010151826020015160028151811061016f5761016f6108a2565b6020026020010151836020015160038151811061018e5761018e6108a2565b602002602001015184602001516004815181106101ad576101ad6108a2565b602002602001015185602001516005815181106101cc576101cc6108a2565b602002602001015186602001516006815181106101eb576101eb6108a2565b6020026020010151876020015160078151811061020a5761020a6108a2565b60200260200101518860200151600881518110610229576102296108a2565b60200260200101518960200151600981518110610248576102486108a2565b60200260200101519a509a509a509a509a509a509a509a509a509a50509193959799509193959799565b60408051600a8082526101608201909252600091816020015b606081526020019060019003908161028b57905050905081816000815181106102b6576102b66108a2565b602002602001018190525081816001815181106102d5576102d56108a2565b602002602001018190525081816002815181106102f4576102f46108a2565b60200260200101819052508181600381518110610313576103136108a2565b60200260200101819052508181600481518110610332576103326108a2565b60200260200101819052508181600581518110610351576103516108a2565b60200260200101819052508181600681518110610370576103706108a2565b6020026020010181905250818160078151811061038f5761038f6108a2565b602002602001018190525081816008815181106103ae576103ae6108a2565b602002602001018190525081816009815181106103cd576103cd6108a2565b6020908102919091018101919091526040805180820182528581529182018390526000549051635c6e105f60e01b81526001600160a01b0390911690635c6e105f9061041d9084906004016108b8565b6020604051808303816000875af115801561043c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610460919061093b565b5050505050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156104a0576104a0610467565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156104cf576104cf610467565b604052919050565b600067ffffffffffffffff8211156104f1576104f1610467565b50601f01601f191660200190565b600082601f83011261051057600080fd5b813561052361051e826104d7565b6104a6565b81815284602083860101111561053857600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561056757600080fd5b813567ffffffffffffffff81111561057e57600080fd5b61058a848285016104ff565b949350505050565b60005b838110156105ad578181015183820152602001610595565b838111156105bc576000848401525b50505050565b600081518084526105da816020860160208601610592565b601f01601f19169290920160200192915050565b60006101408083526106028184018e6105c2565b90508281036020840152610616818d6105c2565b9050828103604084015261062a818c6105c2565b9050828103606084015261063e818b6105c2565b90508281036080840152610652818a6105c2565b905082810360a084015261066681896105c2565b905082810360c084015261067a81886105c2565b905082810360e084015261068e81876105c2565b90508281036101008401526106a381866105c2565b90508281036101208401526106b881856105c2565b9d9c50505050505050505050505050565b600080604083850312156106dc57600080fd5b823567ffffffffffffffff808211156106f457600080fd5b610700868387016104ff565b9350602085013591508082111561071657600080fd5b50610723858286016104ff565b9150509250929050565b60208152600061074060208301846105c2565b9392505050565b600082601f83011261075857600080fd5b815161076661051e826104d7565b81815284602083860101111561077b57600080fd5b61058a826020830160208701610592565b6000602080838503121561079f57600080fd5b825167ffffffffffffffff808211156107b7", "57600080fd5b90840190604082870312156107cb57600080fd5b6107d361047d565b8251828111156107e257600080fd5b6107ee88828601610747565b825250838301518281111561080257600080fd5b80840193505086601f84011261081757600080fd5b82518281111561082957610829610467565b8060051b6108388682016104a6565b918252848101860191868101908a84111561085257600080fd5b87870192505b8383101561088e578251868111156108705760008081fd5b61087e8c8a838b0101610747565b8352509187019190870190610858565b968401969096525090979650505050505050565b634e487b7160e01b600052603260045260246000fd5b6000602080835283516040828501526108d460608501826105c2565b82860151601f198683038101604088015281518084529293509084019183850190600581901b8501860160005b8281101561092d578487830301845261091b8287516105c2565b95880195938801939150600101610901565b509998505050505050505050565b60006020828403121561094d57600080fd5b81518060030b811461074057600080fdfea26469706673582212208b1d406394b4e2aae48ad2ce8115b19145b86232ce9e9060500258ed3fdfc2ff64736f6c634300080b0033"};

    public static final String BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {"60c060405260066080819052651d17dd195cdd60d21b60a090815262000029916001919062000466565b503480156200003757600080fd5b50604051620011e3380380620011e38339810160408190526200005a9162000555565b60408051600a8082526101608201909252600091816020015b60608152602001906001900390816200007357905050905060405180604001604052806002815260200161076360f41b81525081600081518110620000bc57620000bc6200060d565b602002602001018190525060405180604001604052806002815260200161763160f01b81525081600181518110620000f857620000f86200060d565b6020026020010181905250604051806040016040528060028152602001613b1960f11b815250816002815181106200013457620001346200060d565b602002602001018190525060405180604001604052806002815260200161763360f01b815250816003815181106200017057620001706200060d565b6020026020010181905250604051806040016040528060028152602001611d8d60f21b81525081600481518110620001ac57620001ac6200060d565b602002602001018190525060405180604001604052806002815260200161763560f01b81525081600581518110620001e857620001e86200060d565b6020026020010181905250604051806040016040528060028152602001613b1b60f11b815250816006815181106200022457620002246200060d565b602002602001018190525060405180604001604052806002815260200161763760f01b815250816007815181106200026057620002606200060d565b6020026020010181905250604051806040016040528060028152602001610ec760f31b815250816008815181106200029c576200029c6200060d565b602002602001018190525060405180604001604052806002815260200161763960f01b81525081600981518110620002d857620002d86200060d565b602090810291909101810191909152604080516080810182526003918101918252626b657960e81b606082015290815280820183905283519091620003239160019186019062000466565b5060405163656db23160e11b81526110029063cadb6462906200034e90600190859060040162000736565b6020604051808303816000875af11580156200036e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003949190620007d3565b506040516359a48b6560e01b8152600090611002906359a48b6590620003c090600190600401620007ff565b602060405180830381865afa158015620003de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000404919062000814565b90506001600160a01b0381166200043c57604051636381e58960e11b8152602060048201526000602482015260440160405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055506200083f915050565b828054620004749062000623565b90600052602060002090601f016020900481019282620004985760008555620004e3565b82601f10620004b357805160ff1916838001178555620004e3565b82800160010185558215620004e3579182015b82811115620004e3578251825591602001919060010190620004c6565b50620004f1929150620004f5565b5090565b5b80821115620004f15760008155600101620004f6565b63b95aa35560e01b600052604160045260246000fd5b60005b838110156200053f57818101518382015260200162000525565b838111156200054f576000848401525b50505050565b6000602082840312156200056857600080fd5b81516001600160401b03808211156200058057600080fd5b818401915084601f8301126200059557600080fd5b815181811115620005aa57620005aa6200050c565b604051601f8201601f19908116603f01168101908382118183101715620005d557620005d56200050c565b81604052828152876020848701011115620005ef57600080fd5b6200060283602083016020880162000522565b979650505050505050565b63b95aa35560e01b600052603260045260246000fd5b600181811c908216806200063857607f821691505b602082108114156200065a5763b95aa35560e01b600052602260045260246000fd5b50919050565b8054600090600181811c90808316806200067b57607f831692505b60208084108214156200069e5763b95aa35560e01b600052602260045260246000fd5b83885260208801828015620006bc5760018114620006ce57620006fb565b60ff19871682528282019750620006fb565b60008981526020902060005b87811015620006f557815484820152908601908401620006da565b83019850505b5050505050505092915050565b600081518084526200072281602086016020860162000522565b601f01601f19169290920160200192915050565b6040815260006200074b604083018562000660565b60208382038185015284516040835262000769604084018262000708565b9050818601518382038385015281935080518083528383019450838160051b840101848301925060005b82811015620007c557601f19858303018752620007b282855162000708565b9686019693860193915060010162000793565b509998505050505050505050565b600060208284031215620007e657600080fd5b81518060030b8114620007f857600080fd5b9392505050565b602081526000620007f8602083018462000660565b6000602082840312156200082757600080fd5b81516001600160a01b0381168114620007f857600080fd5b610994806200084f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80631a391cb41461003b5780637b1b8e0314610050575b600080fd5b61004e610049366004610555565b610082565b005b61006361005e3660046105b9565b610277565b6040516100799a99989796959493929190610652565b60405180910390f35b60408051600a8082526101608201909252600091816020015b606081526020019060019003908161009b57905050905081816000815181106100c6576100c661072d565b602002602001018190525081816001815181106100e5576100e561072d565b602002602001018190525081816002815181106101045761010461072d565b602002602001018190525081816003815181106101235761012361072d565b602002602001018190525081816004815181106101425761014261072d565b602002602001018190525081816005815181106101615761016161072d565b602002602001018190525081816006815181106101805761018061072d565b6020026020010181905250818160078151811061019f5761019f61072d565b602002602001018190525081816008815181106101be576101be61072d565b602002602001018190525081816009815181106101dd576101dd61072d565b60209081029190910181019190915260408051808201825285815291820183905260005490516304c8b95360e41b81526001600160a01b0390911690634c8b95309061022d908490600401610743565b6020604051808303816000875af115801561024c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027091906107c6565b5050505050565b60608060608060608060608060608060008060009054906101000a90046001600160a01b03166001600160a01b0316635b325d788d6040518263ffffffff1660e01b81526004016102c891906107f0565b600060405180830381865afa1580156102e5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261030d9190810190610848565b905080602001516000815181106103265761032661072d565b602002602001015181602001516001815181106103455761034561072d565b602002602001015182602001516002815181106103645761036461072d565b602002602001015183602001516003815181106103835761038361072d565b602002602001015184602001516004815181106103a2576103a261072d565b602002602001015185602001516005815181106103c1576103c161072d565b602002602001015186602001516006815181106103e0576103e061072d565b602002602001015187602001516007815181106103ff576103ff61072d565b6020026020010151886020015160088151811061041e5761041e61072d565b6020026020010151896020015160098151811061043d5761043d61072d565b60200260200101519a509a509a509a509a509a509a509a509a509a50509193959799509193959799565b63b95aa35560e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156104a0576104a0610467565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156104cf576104cf610467565b604052919050565b600067ffffffffffffffff8211156104f1576104f1610467565b50601f01601f191660200190565b600082601f83011261051057600080fd5b813561052361051e826104d7565b6104a6565b81815284602083860101111561053857600080fd5b816020850160208301376000918101602001919091529392505050565b6000806040838503121561056857600080fd5b823567ffffffffffffffff8082111561058057600080fd5b61058c868387016104ff565b935060208501359150808211156105a257600080fd5b506105af858286016104ff565b9150509250929050565b6000602082840312156105cb57600080fd5b813567ffffffffffffffff8111156105e257600080fd5b6105ee848285016104ff565b949350505050565b60005b838110156106115781810151838201526020016105f9565b83811115610620576000848401525b50505050565b6000815180845261063e8160208601602086016105f6565b601f01601f19169290920160200192915050565b60006101408083526106668184018e610626565b9050828103602084015261067a818d610626565b9050828103604084015261068e818c610626565b905082810360608401526106a2818b610626565b905082810360808401526106b6818a610626565b905082810360a08401526106ca8189610626565b905082810360c08401526106de8188610626565b905082810360e08401526106f28187610626565b90508281036101008401526107078186610626565b905082810361012084015261071c8185610626565b9d9c50505050505050505050505050565b63b95aa35560e01b600052603260045260246000fd5b60006020808352835160408285015261075f6060850182610626565b82860151601f198683038101604088015281518084529293509084019183850190600581901b8501860160005b828110156107b857848783030184526107a6828751610626565b95880195938801939150", "60010161078c565b509998505050505050505050565b6000602082840312156107d857600080fd5b81518060030b81146107e957600080fd5b9392505050565b6020815260006107e96020830184610626565b600082601f83011261081457600080fd5b815161082261051e826104d7565b81815284602083860101111561083757600080fd5b6105ee8260208301602087016105f6565b6000602080838503121561085b57600080fd5b825167ffffffffffffffff8082111561087357600080fd5b908401906040828703121561088757600080fd5b61088f61047d565b82518281111561089e57600080fd5b6108aa88828601610803565b82525083830151828111156108be57600080fd5b80840193505086601f8401126108d357600080fd5b8251828111156108e5576108e5610467565b8060051b6108f48682016104a6565b918252848101860191868101908a84111561090e57600080fd5b87870192505b8383101561094a5782518681111561092c5760008081fd5b61093a8c8a838b0101610803565b8352509187019190870190610914565b96840196909652509097965050505050505056fea26469706673582212202aca9e9a5c49748e4e0dda1c365ad4917e39b9bc7be318d9de184eac9aa0eb7564736f6c634300080b0033"};

    public static final String SM_BINARY = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"id\",\"type\":\"string\"}],\"name\":\"get\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"id\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"v\",\"type\":\"string\"}],\"name\":\"set\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.v3.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_GET = "get";

    public static final String FUNC_SET = "set";

    protected MultiTableTest(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public static String getABI() {
        return ABI;
    }

    public Tuple10<String, String, String, String, String, String, String, String, String, String> get(
            String id) throws ContractException {
        final Function function = new Function(FUNC_GET,
                Arrays.<Type>asList(new Utf8String(id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple10<String, String, String, String, String, String, String, String, String, String>(
                (String) results.get(0).getValue(),
                (String) results.get(1).getValue(),
                (String) results.get(2).getValue(),
                (String) results.get(3).getValue(),
                (String) results.get(4).getValue(),
                (String) results.get(5).getValue(),
                (String) results.get(6).getValue(),
                (String) results.get(7).getValue(),
                (String) results.get(8).getValue(),
                (String) results.get(9).getValue());
    }

    public Function getMethodGetRawFunction(String id) throws ContractException {
        final Function function = new Function(FUNC_GET,
                Arrays.<Type>asList(new Utf8String(id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }));
        return function;
    }

    public TransactionReceipt set(String id, String v) {
        final Function function = new Function(
                FUNC_SET,
                Arrays.<Type>asList(new Utf8String(id),
                        new Utf8String(v)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return executeTransaction(function);
    }

    public Function getMethodSetRawFunction(String id, String v) throws ContractException {
        final Function function = new Function(FUNC_SET,
                Arrays.<Type>asList(new Utf8String(id),
                        new Utf8String(v)),
                Arrays.<TypeReference<?>>asList());
        return function;
    }

    public String getSignedTransactionForSet(String id, String v) {
        final Function function = new Function(
                FUNC_SET,
                Arrays.<Type>asList(new Utf8String(id),
                        new Utf8String(v)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return createSignedTransaction(function);
    }

    public String set(String id, String v, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_SET,
                Arrays.<Type>asList(new Utf8String(id),
                        new Utf8String(v)),
                Collections.<TypeReference<?>>emptyList(), 0);
        return asyncExecuteTransaction(function, callback);
    }

    public Tuple2<String, String> getSetInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_SET,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }));
        List<Type> results = this.functionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<String, String>(

                (String) results.get(0).getValue(),
                (String) results.get(1).getValue()
        );
    }

    public static MultiTableTest load(String contractAddress, Client client,
                                      CryptoKeyPair credential) {
        return new MultiTableTest(contractAddress, client, credential);
    }

    public static MultiTableTest deploy(Client client, CryptoKeyPair credential, String name) throws
            ContractException {
        byte[] encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new Utf8String(name)));
        return deploy(MultiTableTest.class, client, credential, getBinary(client.getCryptoSuite()), getABI(), encodedConstructor, null);
    }
}
